import com.alibaba.druid.pool.DruidDataSource;
import com.msb.Emp;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testbean {
    @Test
    public void test(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationbean.xml");
        Emp emp = applicationContext.getBean("emp",Emp.class);
        System.out.println(emp);
        //测试DruidDataSource 从配置文件里面读取参数并初始化
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationbean.xml");
        DruidDataSource druidDataSource = context.getBean("datasource",DruidDataSource.class);
        System.out.println("druidDataSource = "+druidDataSource.toString()+"\nusername = "+druidDataSource.getUsername()
                +"\npassword = "+druidDataSource.getPassword()+"\nurl = "+druidDataSource.getUrl());
    }
}
